Skip to content

Conversation

@js-murph
Copy link
Collaborator

What

Implements a caching strategy for the Go module proxy as described in https://proxy.golang.org/

Why

To add support for caching go modules

Tests

Implemented unit tests. In addition manual testing was performed as follows...

  1. Create a cachew.hcl:
memory {}

disk {
  root = "./state/cache"
}

gomod {
  proxy = "https://proxy.golang.org"
}
  1. Run the proxy ./cachewd --config cachew.hcl

  2. Manual verification...

$ time curl http://localhost:8080/github.com/alecthomas/kong/@latest
{"Version":"v1.13.0","Time":"2025-11-12T21:31:44Z","Origin":{"VCS":"git","URL":"https://github.com/alecthomas/kong","Hash":"d8de683664a2581e93717b7e4e8f4b55e4beeff4","Ref":"refs/tags/v1.13.0"}}
real	0m0.179s
user	0m0.006s
sys	0m0.011s

$ time curl http://localhost:8080/github.com/alecthomas/kong/@latest
{"Version":"v1.13.0","Time":"2025-11-12T21:31:44Z","Origin":{"VCS":"git","URL":"https://github.com/alecthomas/kong","Hash":"d8de683664a2581e93717b7e4e8f4b55e4beeff4","Ref":"refs/tags/v1.13.0"}}
real	0m0.033s
user	0m0.006s
sys	0m0.013s

@js-murph js-murph requested a review from alecthomas as a code owner January 20, 2026 05:00
@js-murph js-murph added the enhancement New feature or request label Jan 20, 2026
@alecthomas
Copy link
Collaborator

I had another thought - I think we should enforce private repository blocking here, to prevent leaking to upstream public module proxies.

@alecthomas
Copy link
Collaborator

Which did also lead me to wonder whether we should be implementing a full proxy...but I think that's a question for another time.

@alecthomas
Copy link
Collaborator

Actually... https://github.com/goproxy/goproxy is explicitly designed to be embeddable, and has an extensible caching interface. Let's do some due diligence around whether this would be worthwhile to embed.

The advantage this could give us is the ability to cache private repositories.

@js-murph
Copy link
Collaborator Author

Actually... https://github.com/goproxy/goproxy is explicitly designed to be embeddable, and has an extensible caching interface. Let's do some due diligence around whether this would be worthwhile to embed.

The advantage this could give us is the ability to cache private repositories.

Sounds reasonable to me, did we want to merge this as a currently working thing and I can explore the embedded goproxy to replace it?

@alecthomas
Copy link
Collaborator

Yeah let's do it!

@alecthomas alecthomas merged commit 40b1af3 into main Jan 21, 2026
5 of 6 checks passed
@alecthomas alecthomas deleted the johnm/implement-go-mod branch January 21, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants